//
//  My_Detail.m
//  HappyStore
//
//  Created by 点点充 on 16/1/26.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "My_Detail.h"

@interface My_Detail ()
{
    NSArray *aryTitle1;
    NSMutableArray *muAryTitleContent;
    
    NSMutableArray *muAryWork;//工作经历
    NSMutableArray *muAryEducation;//教育经历
    NSMutableArray *muAryHobby;//兴趣爱好
    NSMutableArray *muAryGoodatfield;//擅长领域
    NSMutableArray *muAryMyneeds;//我的需求
    
    UIImage *imgUserHeaderImg;//用户头像
    UIButton *btnHeader;
    UIButton *btnUserName;//用户名称
    
    NSMutableDictionary *dicNoti;//选择的隶属组织
    
    //兴趣爱好
    BOOL isShowTf1;
    BOOL isShowTf2;
    BOOL isShowTf3;
    
    UITextField *tfLove1;
    UIButton *btnOKLove1;
    UITextField *tfLove2;
    UIButton *btnOKLove2;
    UITextField *tfLove3;
    UIButton *btnOKLove3;
    
    NSMutableArray *muArySaveLoveBtn1;
    NSMutableArray *muArySaveLoveBtn2;
    NSMutableArray *muArySaveLoveBtn3;
    
    
}
@end

@implementation My_Detail


- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.tabBarController.tabBar.hidden = YES;
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    NSMutableString *muStr = [NSMutableString string];
    BOOL isNull = NO;
    if (_dicInfo[@"companyAccount"] == [NSNull null] || [_dicInfo[@"companyAccount"] isEqualToString:@"null"]) {
        if (_dicInfo[@"companyUserName"] == [NSNull null] || [_dicInfo[@"companyUserName"] isEqualToString:@"null"] ) {
            isNull = YES;
        }
        
    }else {
        if (_dicInfo[@"companyUserName"] == [NSNull null] || [_dicInfo[@"companyUserName"] isEqualToString:@"null"]) {
            [muStr appendFormat:@"%@",_dicInfo[@"companyAccount"]];
        }else {
            [muStr appendFormat:@"%@",_dicInfo[@"companyUserName"]];
        }
        
    }
    
    
    if (_dicInfo[@"goveAccount"] == [NSNull null] || [_dicInfo[@"goveAccount"] isEqualToString:@"null"]) {
        if (_dicInfo[@"goveUserName"] == [NSNull null] || [_dicInfo[@"goveUserName"] isEqualToString:@"null"]) {
            if (isNull) {
                [muStr appendString:@"无"];
            }
            
        }
    }else {
        if (_dicInfo[@"goveUserName"] == [NSNull null] || [_dicInfo[@"goveUserName"] isEqualToString:@"null"]) {
            [muStr appendFormat:@"%@",_dicInfo[@"goveAccount"]];
        }else {
            [muStr appendFormat:@"%@",_dicInfo[@"goveUserName"]];
        }
        
    }
    
    isShowTf1 = NO;
    isShowTf2 = NO;
    isShowTf3 = NO;
    muArySaveLoveBtn1 = [NSMutableArray array];
    muArySaveLoveBtn2 = [NSMutableArray array];
    muArySaveLoveBtn3 = [NSMutableArray array];
    
    //性别：sex 年龄：age 职位：positionName 隶属组织：判断 个性：signature 所在地：address 电话：mobile
    aryTitle1 = @[@"性        别:",@"年        龄:",@"职        位:",@"隶属组织:",@"个性签名:",@"所在地区:",@"联系电话:"];
    muAryTitleContent = [NSMutableArray arrayWithObjects:_dicInfo[@"sex"],_dicInfo[@"age"],_dicInfo[@"positionName"],
                         muStr,_dicInfo[@"signature"],_dicInfo[@"address"],
                         _dicInfo[@"mobile"], nil];
    
    //兴趣爱好：hobby 擅长领域：goodatfield 我的需求：myneeds
    NSString *strHobby = _dicInfo[@"hobby"];
    if (strHobby.length != 0 && ![strHobby isEqualToString:@"null"]) {
        muAryHobby = [NSMutableArray arrayWithArray:[_dicInfo[@"hobby"] componentsSeparatedByString:NSLocalizedString(@",", nil)]];
    }else {
        [_dicInfo setObject:@"" forKey:@"hobby"];
        muAryHobby = [NSMutableArray array];
    }
    
    NSString *strGoodatfield = _dicInfo[@"goodatfield"];
    if (strGoodatfield.length != 0 && ![strGoodatfield isEqualToString:@"null"]) {
        muAryGoodatfield = [NSMutableArray arrayWithArray:[_dicInfo[@"goodatfield"] componentsSeparatedByString:NSLocalizedString(@",", nil)]];
    }else {
        [_dicInfo setObject:@"" forKey:@"goodatfield"];
        muAryGoodatfield = [NSMutableArray array];
    }
    
    NSString *strMyneeds = _dicInfo[@"myneeds"];
    if (strMyneeds.length != 0 && ![strMyneeds isEqualToString:@"null"]) {
        muAryMyneeds = [NSMutableArray arrayWithArray:[_dicInfo[@"myneeds"] componentsSeparatedByString:NSLocalizedString(@",", nil)]];
    }else {
        [_dicInfo setObject:@"" forKey:@"myneeds"];
        muAryMyneeds = [NSMutableArray array];
    }
    
    
    
    //工作经历  work
    if ([_dicInfo[@"work"] isKindOfClass:[NSString class]]) {
        muAryWork = [NSMutableArray array];
    }else {
        muAryWork = [NSMutableArray arrayWithArray:_dicInfo[@"work"]];
    }
    
    //教育经历  education schoolIng学历 schoolStudy专业
    if ([_dicInfo[@"education"] isKindOfClass:[NSString class]]) {
        muAryEducation = [NSMutableArray array];
    }else {
      muAryEducation = [NSMutableArray arrayWithArray:_dicInfo[@"education"]];
    }
    
    
    
    
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
//    NSLog(@"%ld",1+aryTitle1.count+3+4+muAryWork.count+muAryEducation.count);
    return 1+aryTitle1.count+3+4+muAryWork.count+muAryEducation.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 166;
    }else if (indexPath.row < aryTitle1.count+1) {//个人信息
        return 44;
    }else if (indexPath.row < aryTitle1.count+1+3) {//爱好
        return 70;
    }else if (indexPath.row == aryTitle1.count+1+3) {//工作经历
        return 44;
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1) {
        return 100;
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1) {//添加工作经历
        return 44;
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+1) {//教育经历
        return 44;
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//
        return 100;
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//添加教育经历
        return 44;
    }else {
        return 44;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellHeader = @"cellHeader";//头像
    static NSString *cellSex = @"cellSex";//个人信息多条
    static NSString *cellLove = @"cellLove";//爱好
    static NSString *cellTitle = @"cellTitle";//标题：工作经历、教育经历
    static NSString *cellAdd = @"cellAdd";//添加按钮
    static NSString *cellExp = @"cellExp";//具体经历
    
    UITableViewCell *cell;
    
    if (indexPath.row == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:cellHeader forIndexPath:indexPath];
        //头像
        btnHeader = [cell viewWithTag:10];
        btnHeader.layer.masksToBounds = YES;
        btnHeader.layer.cornerRadius = 35;
        [btnHeader setImage:nil forState:UIControlStateNormal];
        [btnHeader sd_setBackgroundImageWithURL:[NSURL URLWithString:_dicInfo[@"headPhoto"]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"btn_my_touxiang"]];
//        [btnHeader sd_setImageWithURL:[NSURL URLWithString:_dicInfo[@"headPhoto"]] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"btn_my_touxiang"]];
        [btnHeader addTarget:self action:@selector(btnClickEditHeaderImg) forControlEvents:UIControlEventTouchUpInside];
        
        UIImageView *imgVip = [cell viewWithTag:11];
        if ([_dicInfo[@"vipLevel"] integerValue] == 0) {
            imgVip.image = [UIImage imageNamed:@"img_my_vip2"];
        }else {
            imgVip.image = [UIImage imageNamed:@"img_my_vip1"];
        }
        //名称
        btnUserName = [cell viewWithTag:12];
        if (_dicInfo[@"username"] == [NSNull null] || [_dicInfo[@"username"] isEqualToString:@"null"]) {
            [btnUserName setTitle:_dicInfo[@"account"] forState:UIControlStateNormal];
        }else {
            [btnUserName setTitle:_dicInfo[@"username"] forState:UIControlStateNormal];
        }
        [btnUserName addTarget:self action:@selector(btnClickEditUserName) forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    else if (indexPath.row <aryTitle1.count+1) {//个人信息
        cell = [tableView dequeueReusableCellWithIdentifier:cellSex forIndexPath:indexPath];
        
        UILabel *labTitle = [cell viewWithTag:10];
        labTitle.text = aryTitle1[indexPath.row-1];
        
        UILabel *labContent = [cell viewWithTag:11];
        labContent.text = muAryTitleContent[indexPath.row-1];
    }
    
    else if (indexPath.row <aryTitle1.count+1+3) {//爱好
        cell = [tableView dequeueReusableCellWithIdentifier:cellLove forIndexPath:indexPath];
        
        NSArray *ary1 = @[@"兴趣爱好:",@"擅长领域:",@"我的需求:"];
        UILabel *labTitle = [cell viewWithTag:10];
        labTitle.text = ary1[indexPath.row-aryTitle1.count-1];
        
        UITextField *tf = [cell viewWithTag:11];
        tf.hidden = YES;
        
        
        
        UIButton *btnOK = [cell viewWithTag:12];
        btnOK.hidden = YES;
//        btnOK.tag = 100 + 10*(indexPath.row - aryTitle1.count - 1);
        [btnOK addTarget:self action:@selector(btnLoveOk:) forControlEvents:UIControlEventTouchUpInside];
        
        [self addLoveView:cell withIndexPath:indexPath withTf:tf withBtn:btnOK];
        
        
        
        
    }
    
    
    else if (indexPath.row == aryTitle1.count+1+3) {//工作经历
        cell = [tableView dequeueReusableCellWithIdentifier:cellTitle forIndexPath:indexPath];
        UILabel *labTitle = [cell viewWithTag:10];
        labTitle.text = @"工作经历";
        
    }
    else if (indexPath.row <aryTitle1.count+1+3+muAryWork.count+1) {
        cell = [tableView dequeueReusableCellWithIdentifier:cellExp forIndexPath:indexPath];
        
        UIImageView *imgLogo = [cell viewWithTag:10];
        imgLogo.layer.masksToBounds = YES;
        imgLogo.layer.cornerRadius = 27.f;
        [imgLogo sd_setImageWithURL:[NSURL URLWithString:muAryWork[indexPath.row-aryTitle1.count-5][@"workLogo"]] placeholderImage:[UIImage imageNamed:@"btn_my_touxiang"]];
        
        UIImageView *img1 = [cell viewWithTag:11];
        img1.image = [UIImage imageNamed:@"btn_myD_gz1"];
        UIImageView *img2 = [cell viewWithTag:13];
        img2.image = [UIImage imageNamed:@"btn_myD_gz2"];
        UIImageView *img3 = [cell viewWithTag:15];
        img3.image = [UIImage imageNamed:@"btn_myD_gz3"];
        
        UILabel *lab1 = [cell viewWithTag:12];
        lab1.text = muAryWork[indexPath.row-aryTitle1.count-5][@"workPosition"];
        UILabel *lab2 = [cell viewWithTag:14];
        lab2.text = muAryWork[indexPath.row-aryTitle1.count-5][@"workName"];
        UILabel *lab3 = [cell viewWithTag:16];
        lab3.text = muAryWork[indexPath.row-aryTitle1.count-5][@"workTime"];
        
        
    }
    else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1) {//添加工作经历
        cell = [tableView dequeueReusableCellWithIdentifier:cellAdd forIndexPath:indexPath];
        UILabel *labTitle = [cell viewWithTag:10];
        labTitle.text = @"添加工作经历";
    }
    
    
    else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+2) {//教育经历
        cell = [tableView dequeueReusableCellWithIdentifier:cellTitle forIndexPath:indexPath];
        UILabel *labTitle = [cell viewWithTag:10];
        labTitle.text = @"教育经历";
    }
    else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+3+muAryEducation.count) {//
        cell = [tableView dequeueReusableCellWithIdentifier:cellExp forIndexPath:indexPath];
        
        UIImageView *imgLogo = [cell viewWithTag:10];
        imgLogo.layer.masksToBounds = YES;
        imgLogo.layer.cornerRadius = 27.f;
        [imgLogo sd_setImageWithURL:[NSURL URLWithString:muAryEducation[indexPath.row-aryTitle1.count-muAryWork.count-7][@"schoolLogo"]] placeholderImage:[UIImage imageNamed:@"btn_my_touxiang"]];
        
        UIImageView *img1 = [cell viewWithTag:11];
        img1.translatesAutoresizingMaskIntoConstraints = YES;
        CGRect rect1 = img1.frame;
        rect1.size.height = 13;
        rect1.size.width = 13;
        img1.frame = rect1;
        img1.image = [UIImage imageNamed:@"btn_myD_jy1"];
        UIImageView *img2 = [cell viewWithTag:13];
        img2.image = [UIImage imageNamed:@"btn_myD_jy2"];
        UIImageView *img3 = [cell viewWithTag:15];
        img3.image = [UIImage imageNamed:@"btn_myD_gz3"];
        
        UILabel *lab1 = [cell viewWithTag:12];//schoolStudy专业
        lab1.text = muAryEducation[indexPath.row-aryTitle1.count-muAryWork.count-7][@"schoolStudy"];
        UILabel *lab2 = [cell viewWithTag:14];
        lab2.text = muAryEducation[indexPath.row-aryTitle1.count-muAryWork.count-7][@"schoolName"];
        UILabel *lab3 = [cell viewWithTag:16];
        lab3.text = muAryEducation[indexPath.row-aryTitle1.count-muAryWork.count-7][@"schoolTime"];
        
    }
    else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+3+muAryEducation.count) {//添加教育经历
        cell = [tableView dequeueReusableCellWithIdentifier:cellAdd forIndexPath:indexPath];
        UILabel *labTitle = [cell viewWithTag:10];
        labTitle.text = @"添加教育经历";
    }
    
    
    
    
    
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];//取消选中状态
    
    //取消显示后退键文字
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    self.navigationItem.backBarButtonItem = barButtonItem;
    
    
    if (indexPath.row == 0) {
        
    }else if (indexPath.row < aryTitle1.count+1) {//个人信息
//        aryTitle1 = @[@"性        别:",@"年        龄:",@"职        位:",@"隶属组织:",@"个性签名:",@"所在地区:",@"联系电话:"];
        switch (indexPath.row-1) {
            case 0://性别
            {
                UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"照片选择"
                                                                         delegate:self
                                                                cancelButtonTitle:@"取消"
                                                           destructiveButtonTitle:nil
                                                                otherButtonTitles:@"男",@"女", nil];
                actionSheet.tag = 100;
                [actionSheet showInView:self.view];
            }
                break;
            case 1://年龄
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"年龄" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
                alert.alertViewStyle = UIAlertViewStylePlainTextInput;
                UITextField *nameField = [alert textFieldAtIndex:0];
                nameField.placeholder = @"请输入您的年龄";
                nameField.keyboardType = UIKeyboardTypePhonePad;
                
                [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
                    if(buttonIndex == 1){
                        UITextField *tf=[alert textFieldAtIndex:0];
                        if (tf.text.length > 0) {
                            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
                            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                            [muDicParameters setObject:tf.text forKey:@"age"];//资源类型
                            
                            [self startEditeUserInfoWithDic:muDicParameters withType:3];
                        }
                    }
                }];
            }
                break;
            case 2://职位
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"职位" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
                alert.alertViewStyle = UIAlertViewStylePlainTextInput;
                UITextField *nameField = [alert textFieldAtIndex:0];
                nameField.placeholder = @"请输入您的职位";
                
                [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
                    if(buttonIndex == 1){
                        UITextField *tf=[alert textFieldAtIndex:0];
                        if (tf.text.length > 0) {
                            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
                            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                            [muDicParameters setObject:tf.text forKey:@"positionName"];//资源类型
                            
                            [self startEditeUserInfoWithDic:muDicParameters withType:4];
                        }
                    }
                }];
            }
                break;
            case 3://隶属组织
            {
//                [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setLiShuZuzhi:) name:@"setLiShuZuzhi" object:nil];
//                [self performSegueWithIdentifier:@"mylishuzuzhi" sender:self];
            }
                break;
            case 4://个性签名
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"个性签名" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
                alert.alertViewStyle = UIAlertViewStylePlainTextInput;
                UITextField *nameField = [alert textFieldAtIndex:0];
                nameField.placeholder = @"请输入您的个性签名";
                
                [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
                    if(buttonIndex == 1){
                        UITextField *tf=[alert textFieldAtIndex:0];
                        if (tf.text.length > 0) {
                            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
                            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                            [muDicParameters setObject:tf.text forKey:@"signature"];//资源类型
                            
                            [self startEditeUserInfoWithDic:muDicParameters withType:6];
                        }
                    }
                }];
            }
                break;
            case 5://所在地区
            {
                SelectedAddress *selectAddress = [SelectedAddress sharedSelectedAddress];
                selectAddress.delegatee = self;
                [selectAddress btnClickAddress];
            }
                break;
            case 6://联系电话
            {
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"联系电话" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
                alert.alertViewStyle = UIAlertViewStylePlainTextInput;
                UITextField *nameField = [alert textFieldAtIndex:0];
                nameField.placeholder = @"请输入您的联系电话";
                nameField.keyboardType = UIKeyboardTypePhonePad;
                
                [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
                    if(buttonIndex == 1){
                        UITextField *tf=[alert textFieldAtIndex:0];
                        if (tf.text.length > 0) {
                            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
                            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                            [muDicParameters setObject:tf.text forKey:@"mobile"];//资源类型
                            
                            [self startEditeUserInfoWithDic:muDicParameters withType:8];
                        }
                    }
                }];
            }
                break;
        }
    }else if (indexPath.row < aryTitle1.count+1+3) {//爱好
        
    }else if (indexPath.row == aryTitle1.count+1+3) {//工作经历
        
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1) {
        
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1) {//添加工作经历
        workExpView *work = [workExpView sharedSelectedAddress];
        work.delegatee = self;
        [work addEduExpWith:self];
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+1) {//教育经历
        
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//
        
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//添加教育经历
        
        [self addEducation];
    }
    
    
}

#pragma mark - 修改头像
- (void)btnClickEditHeaderImg
{
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"照片选择"
                                                             delegate:self
                                                    cancelButtonTitle:@"取消"
                                               destructiveButtonTitle:nil
                                                    otherButtonTitles:@"相机",@"相册", nil];
    actionSheet.tag = 200;
    [actionSheet showInView:self.view];
}

#pragma mark - 选择照片
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    switch (actionSheet.tag) {
        case 100://性别
        {
            //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
            NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
            [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
            switch (buttonIndex) {
                case 0:
                {
                    [muDicParameters setObject:@"男" forKey:@"sex"];//性别
                    [self startEditeUserInfoWithDic:muDicParameters withType:2];
                }
                    break;
                case 1:
                {
                    [muDicParameters setObject:@"女" forKey:@"sex"];//性别
                    [self startEditeUserInfoWithDic:muDicParameters withType:2];
                }
                    break;
                case 2:
                {
                    //取消
                }
                    break;
                    
                default:
                    break;
            }
        }
            break;
        case 200://头像
        {
            //先设定sourceType为相机，然后判断相机是否可用（ipod）没相机，不可用将sourceType设定为相片库
            UIImagePickerController *pickerImage = [[UIImagePickerController alloc] init];
            pickerImage.delegate = self;
            pickerImage.allowsEditing = YES;//设置可编辑
            switch (buttonIndex) {
                case 0:
                {
                    NSLog(@"相机");
                    pickerImage.sourceType = UIImagePickerControllerSourceTypeCamera;
                    [self presentViewController:pickerImage animated:YES completion:nil];//进入照相界面
                }
                    break;
                case 1:
                {
                    NSLog(@"相册");
                    pickerImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; //图片库
                    [self presentViewController:pickerImage animated:YES completion:nil];//进入照相界面
                }
                    break;
                case 2:
                {
                    NSLog(@"取消");
                }
                    break;
            }
        }
            break;
            
        default:
            break;
    }
    
    
    
}

//点击相册中的图片 货照相机照完后点击use  后触发的方法
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    [picker dismissViewControllerAnimated:YES completion:^{}];
    
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    //    [_btnUserImg setImage:image forState:UIControlStateNormal];
    //    _btnUserImg.layer.masksToBounds = YES;
    //    _btnUserImg.layer.cornerRadius = 20.0;
    /* 此处info 有六个值
     * UIImagePickerControllerMediaType; // an NSString UTTypeImage)
     * UIImagePickerControllerOriginalImage;  // a UIImage 原始图片
     * UIImagePickerControllerEditedImage;    // a UIImage 裁剪后图片
     */
    // 保存图片至本地，方法见下文
    //    NSString *strName = [NSString stringWithFormat:@"%@.jpg",[self dateString]];
    //    [self saveImage:image withName:strName];
    
    
    imgUserHeaderImg = image;
    
    [self startEditeHeaderImage];
}

//点击cancel 调用的方法
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [picker dismissViewControllerAnimated:YES completion:^{}];
}

#pragma mark - 保存图片至沙盒
- (void) saveImage:(UIImage *)currentImage withName:(NSString *)imageName
{
    NSData *imageData = UIImageJPEGRepresentation(currentImage, 0.1);
    // 获取沙盒目录
    NSString *fullPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:imageName];
    // 将图片写入文件
    [imageData writeToFile:fullPath atomically:NO];
}


#pragma mark 照片的时间名称
- (NSString*)dateString
{
    NSMutableString*string=[[NSMutableString alloc] init];
    NSDate*dayDate=[NSDate date];
    NSDateFormatter*dayFormatter=[[NSDateFormatter alloc] init];
    [dayFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateStrings= [dayFormatter stringFromDate:dayDate];
    NSArray*dayArray=[dateStrings componentsSeparatedByString:@"-"];
    for (int i=0; i<[dayArray count]; i++) {
        [string appendFormat:@"%@",[dayArray objectAtIndex:i]];
    }
    NSDate*timeDate=[NSDate date];
    NSDateFormatter*timeFormatter=[[NSDateFormatter alloc] init];
    [timeFormatter setDateFormat:@"HH:mm:ss:SSS"];
    NSString *timeString= [timeFormatter stringFromDate:timeDate];
    NSArray*timeArray=[timeString componentsSeparatedByString:@":"];
    for (int i=0; i<[timeArray count]; i++) {
        [string appendFormat:@"%@",[timeArray objectAtIndex:i]];
    }
    return string;
    
}

#pragma mark - 开始上传头像
- (void)startEditeHeaderImage
{
    //token=rE3F2m8AvfC7CVh85O9q&userId=9 参数说明：photo-为图片
    [self showRoundProgressWithTitle:@"请稍后..."];
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    
    NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"changePhoto_app_myHome.im.lensum"];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    [manager POST:strURl parameters:muDicParameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        NSData *imageData = UIImageJPEGRepresentation(imgUserHeaderImg, 0.5);
        [formData appendPartWithFileData:imageData name:@"photo" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([dicInfo[@"result"] integerValue] == 1) {
            [btnHeader setImage:imgUserHeaderImg forState:UIControlStateNormal];
            [_dicInfo setObject:dicInfo[@"data"][0] forKey:@"headPhoto"];

            [self showRightWithTitle:dicInfo[@"msg"] autoCloseTime:2];
        }else {

            [self showSingleIconBubble:dicInfo[@"msg"]];
        }

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showSingleIconBubble:error.localizedDescription];

    }];

}

#pragma mark - 用户昵称
- (void)btnClickEditUserName
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"用户昵称" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
    alert.alertViewStyle = UIAlertViewStylePlainTextInput;
    UITextField *nameField = [alert textFieldAtIndex:0];
    nameField.placeholder = @"请输入您的昵称";
    
    [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
        if(buttonIndex == 1){
            UITextField *tf=[alert textFieldAtIndex:0];
            if (tf.text.length > 0) {
                //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
                NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
                [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
                [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
                [muDicParameters setObject:tf.text forKey:@"userName"];//资源类型
                
                [self startEditeUserInfoWithDic:muDicParameters withType:1];
            }
        }
    }];
}

- (void)startEditeUserInfoWithDic:(NSDictionary *)dicc withType:(NSInteger)type
{
    //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
    
    [self showRoundProgressWithTitle:@"请稍后..."];
    
    NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"updateUser_People_app_myHome.im.lensum"];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:dicc progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            switch (type) {
                case 1://修改用户名
                {
                    [_dicInfo setObject:dicc[@"userName"] forKey:@"username"];
                    [btnUserName setTitle:dicc[@"userName"] forState:UIControlStateNormal];
                }
                    break;
                case 2://性别
                {
                    [_dicInfo setObject:dicc[@"sex"] forKey:@"sex"];
                    [muAryTitleContent replaceObjectAtIndex:0 withObject:dicc[@"sex"]];
                    [self.mainTableView reloadData];
                }
                    break;
                case 3://年龄
                {
                    [_dicInfo setObject:dicc[@"age"] forKey:@"age"];
                    [muAryTitleContent replaceObjectAtIndex:1 withObject:dicc[@"age"]];
                    [self.mainTableView reloadData];
                }
                    break;
                case 4://职位
                {
                    [_dicInfo setObject:dicc[@"positionName"] forKey:@"positionName"];
                    [muAryTitleContent replaceObjectAtIndex:2 withObject:dicc[@"positionName"]];
                    [self.mainTableView reloadData];
                }
                    break;
                case 5://隶属组织
                {
                    NSString *str1 = @"";
                    if (dicNoti[@"username"] == [NSNull null] || [dicNoti[@"username"] isEqualToString:@"null"]) {
                        str1 = dicNoti[@"account"];
                    }else {
                        str1 = dicNoti[@"username"];
                    }
                    [muAryTitleContent replaceObjectAtIndex:3 withObject:str1];
                    [self.mainTableView reloadData];
                }
                    break;
                case 6://个性签名
                {
                    [_dicInfo setObject:dicc[@"signature"] forKey:@"signature"];
                    [muAryTitleContent replaceObjectAtIndex:4 withObject:dicc[@"signature"]];
                    [self.mainTableView reloadData];
                }
                    break;
                case 7://所在地
                {
                    [_dicInfo setObject:dicc[@"address"] forKey:@"address"];
                    [muAryTitleContent replaceObjectAtIndex:5 withObject:dicc[@"address"]];
                    [self.mainTableView reloadData];
                }
                    break;
                case 8://联系电话
                {
                    [_dicInfo setObject:dicc[@"mobile"] forKey:@"mobile"];
                    [muAryTitleContent replaceObjectAtIndex:6 withObject:dicc[@"mobile"]];
                    [self.mainTableView reloadData];
                }
                    break;
                    
                default:
                    break;
            }

            [self showRightWithTitle:[dicInfo objectForKey:@"msg"] autoCloseTime:2];
        }else {

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
        }

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showErrorWithTitle:@"1" autoCloseTime:2];

    }];
}

#pragma mark - 所在地代理
- (void)seceltedRowSshowMsg:(NSString *)showMsg andProvince:(NSString *)strProvince andCity:(NSString *)strCity andDistrict:(NSString *)strDistrict
{
    //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:showMsg forKey:@"address"];//资源类型
    
    [self startEditeUserInfoWithDic:muDicParameters withType:7];
}

#pragma mark - 设置隶属组织
- (void)setLiShuZuzhi:(NSNotification *)dic
{
    dicNoti = [NSMutableDictionary dictionaryWithDictionary:dic.userInfo];//通过这个获取到传递的对象
    
    //token=验证用户&userId=用户id&userName=修改用户名&sex=性别&age=年龄&positionName=职位&shipUserId=上属用户id&shipUserType=上属用户类别&address=地址&mobile=联系电话
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:dicNoti[@"userId"] forKey:@"shipUserId"];//上属用户id
    [muDicParameters setObject:dicNoti[@"userType"] forKey:@"shipUserType"];//上属用户类别
    
    [self startEditeUserInfoWithDic:muDicParameters withType:5];
}

#pragma mark - 修改兴趣爱好
- (void)btnClickEditLove:(UIButton *)sender
{
    NSInteger itemType = (sender.tag - 20)/10;
    
    switch (itemType) {
        case 0://兴趣爱好
        {
            isShowTf1 = YES;
            tfLove1.hidden = NO;
            tfLove1.text = _dicInfo[@"hobby"];
            btnOKLove1.hidden = NO;
            for (UIButton *btn in muArySaveLoveBtn1) {
                btn.hidden = YES;
            }
        }
            break;
        case 1://擅长领域
        {
            isShowTf2 = YES;
            tfLove2.hidden = NO;
            tfLove2.text = _dicInfo[@"goodatfield"];
            btnOKLove2.hidden = NO;
            for (UIButton *btn in muArySaveLoveBtn2) {
                btn.hidden = YES;
            }
        }
            break;
        case 2://我的需求
        {
            isShowTf3 = YES;
            tfLove3.hidden = NO;
            tfLove3.text = _dicInfo[@"myneeds"];
            btnOKLove3.hidden = NO;
            for (UIButton *btn in muArySaveLoveBtn3) {
                btn.hidden = YES;
            }
        }
            break;
    }
    
//    [self.mainTableView reloadData];
    
}

- (void)addLoveView:(UITableViewCell *)cell withIndexPath:(NSIndexPath *)indexPath withTf:(UITextField *)tf withBtn:(UIButton *)btnOK
{
    switch (indexPath.row - aryTitle1.count - 1) {
        case 0:
        {
            tfLove1 = tf;
            btnOKLove1 = btnOK;
            if (isShowTf1) {
                tf.hidden = NO;
                btnOK.hidden = NO;
            }else if(muArySaveLoveBtn1.count == 0) {
                
                for (int i = 0; i<muAryHobby.count; i++) {
                    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                    [btn setTitle:muAryHobby[i] forState:UIControlStateNormal];
                    btn.frame = (CGRect){80+75*(i%3),10+33*(i/3),70,25};
                    btn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
                    
                    [btn addTarget:self action:@selector(btnClickEditLove:) forControlEvents:UIControlEventTouchUpInside];
                    btn.layer.masksToBounds = YES;
                    [btn setTitleColor:[UIColor colorWithRed:255/255.0f green:107/255.0f blue:80/255.0f alpha:1.0f] forState:UIControlStateNormal];
                    btn.layer.borderColor = [UIColor colorWithRed:255/255.0f green:107/255.0f blue:80/255.0f alpha:1.0f].CGColor;;
                    btn.layer.borderWidth = 1.0f;
                    btn.layer.cornerRadius = 5.0f;
                    btn.tag = 20+10*(indexPath.row - aryTitle1.count - 1) +i;
                    
                    [cell addSubview:btn];
                    NSLog(@"-------➕1%@",btn);
                    [muArySaveLoveBtn1 addObject:btn];
                }
                
                if (muAryHobby.count == 0) {
                    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                    [btn setTitle:@"+" forState:UIControlStateNormal];
                    btn.frame = (CGRect){80,10,70,25};
                    [btn setTitleColor:[UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f] forState:UIControlStateNormal];
                    btn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
                    
                    [btn addTarget:self action:@selector(btnClickEditLove:) forControlEvents:UIControlEventTouchUpInside];
                    btn.layer.masksToBounds = YES;
                    btn.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
                    btn.layer.borderWidth = 1.0f;
                    btn.layer.cornerRadius = 5.0f;
                    btn.tag = 20+10*(indexPath.row - aryTitle1.count - 1);
                    
                    [cell addSubview:btn];
                    [muArySaveLoveBtn1 addObject:btn];
                }
            }
        }
            break;
        case 1:
        {
            tfLove2 = tf;
            btnOKLove2 = btnOK;
            
            if (isShowTf2) {
                tf.hidden = NO;
                btnOK.hidden = NO;
            }else if(muArySaveLoveBtn2.count == 0) {
                for (int i = 0; i<muAryGoodatfield.count; i++) {
                    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                    [btn setTitle:muAryGoodatfield[i] forState:UIControlStateNormal];
                    btn.frame = (CGRect){80+75*(i%3),10+33*(i/3),70,25};
                    btn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
                    
                    [btn addTarget:self action:@selector(btnClickEditLove:) forControlEvents:UIControlEventTouchUpInside];
                    btn.layer.masksToBounds = YES;
                    [btn setTitleColor:[UIColor colorWithRed:255/255.0f green:107/255.0f blue:80/255.0f alpha:1.0f] forState:UIControlStateNormal];
                    btn.layer.borderColor = [UIColor colorWithRed:255/255.0f green:107/255.0f blue:80/255.0f alpha:1.0f].CGColor;;
                    btn.layer.borderWidth = 1.0f;
                    btn.layer.cornerRadius = 5.0f;
                    btn.tag = 20+10*(indexPath.row - aryTitle1.count - 1) +i;
                    
                    [cell addSubview:btn];
                    [muArySaveLoveBtn2 addObject:btn];
                }
                
                if (muAryGoodatfield.count == 0) {
                    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                    [btn setTitle:@"+" forState:UIControlStateNormal];
                    btn.frame = (CGRect){80,10,70,25};
                    [btn setTitleColor:[UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f] forState:UIControlStateNormal];
                    btn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
                    
                    [btn addTarget:self action:@selector(btnClickEditLove:) forControlEvents:UIControlEventTouchUpInside];
                    btn.layer.masksToBounds = YES;
                    btn.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
                    btn.layer.borderWidth = 1.0f;
                    btn.layer.cornerRadius = 5.0f;
                    btn.tag = 20+10*(indexPath.row - aryTitle1.count - 1);
                    
                    [cell addSubview:btn];
                    [muArySaveLoveBtn2 addObject:btn];
                }
            }
            
            
            
        }
            break;
        case 2:
        {
            tfLove3 = tf;
            btnOKLove3 = btnOK;
            if (isShowTf3) {
                tf.hidden = NO;
                btnOK.hidden = NO;
            }else if(muArySaveLoveBtn3.count == 0) {
                for (int i = 0; i<muAryMyneeds.count; i++) {
                    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                    [btn setTitle:muAryMyneeds[i] forState:UIControlStateNormal];
                    btn.frame = (CGRect){80+75*(i%3),10+33*(i/3),70,25};
                    btn.titleLabel.font = [UIFont systemFontOfSize:13.0f];
                    
                    [btn addTarget:self action:@selector(btnClickEditLove:) forControlEvents:UIControlEventTouchUpInside];
                    btn.layer.masksToBounds = YES;
                    [btn setTitleColor:[UIColor colorWithRed:255/255.0f green:107/255.0f blue:80/255.0f alpha:1.0f] forState:UIControlStateNormal];
                    btn.layer.borderColor = [UIColor colorWithRed:255/255.0f green:107/255.0f blue:80/255.0f alpha:1.0f].CGColor;;
                    btn.layer.borderWidth = 1.0f;
                    btn.layer.cornerRadius = 5.0f;
                    btn.tag = 20+10*(indexPath.row - aryTitle1.count - 1) +i;
                    
                    [cell addSubview:btn];
                    [muArySaveLoveBtn3 addObject:btn];
                }
                
                if (muAryMyneeds.count == 0) {
                    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                    [btn setTitle:@"+" forState:UIControlStateNormal];
                    btn.frame = (CGRect){80,10,70,25};
                    [btn setTitleColor:[UIColor colorWithRed:137/255.0f green:137/255.0f blue:137/255.0f alpha:1.0f] forState:UIControlStateNormal];
                    btn.titleLabel.font = [UIFont systemFontOfSize:16.0f];
                    
                    [btn addTarget:self action:@selector(btnClickEditLove:) forControlEvents:UIControlEventTouchUpInside];
                    btn.layer.masksToBounds = YES;
                    btn.layer.borderColor = [UIColor colorWithRed:201/255.0f green:202/255.0f blue:202/255.0f alpha:1.0f].CGColor;
                    btn.layer.borderWidth = 1.0f;
                    btn.layer.cornerRadius = 5.0f;
                    btn.tag = 20+10*(indexPath.row - aryTitle1.count - 1);
                    
                    [cell addSubview:btn];
                    [muArySaveLoveBtn3 addObject:btn];
                }
            }
        }
            break;
    }
    
    
}


- (void)btnLoveOk:(UIButton *)sender
{
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    //token=验证用户&userId=用户id&hobby=我的爱好&myneeds=我的需求&goodatfield=我擅长的领域 多个用引文逗号隔开
    
    if (sender == btnOKLove1) {//兴趣爱好
        NSMutableArray *ary1 = [NSMutableArray arrayWithArray:[tfLove1.text componentsSeparatedByString:NSLocalizedString(@"，", nil)]];
        NSMutableString *str1 = [NSMutableString string];
        for (int i = 0; i<ary1.count; i++) {
            NSString *strC = ary1[i];
            if (strC.length>5) {
                [ary1 removeObject:strC];
            }else {
                [str1 appendString:strC];
                [str1 appendString:@","];
            }
        }
        if (ary1.count != 0 && ary1.count<7) {
            [str1 deleteCharactersInRange:NSMakeRange(str1.length-1, 1)];
            
            [muDicParameters setObject:str1 forKey:@"hobby"];//我的爱好
            [self startEditeHobbyInfoWithDic:muDicParameters withType:1];
        }else {
            isShowTf1 = NO;
            muArySaveLoveBtn1 = [NSMutableArray array];
            [_mainTableView reloadData];
        }
        
    }else if (sender == btnOKLove2) {//擅长领域
        NSMutableArray *ary1 = [NSMutableArray arrayWithArray:[tfLove2.text componentsSeparatedByString:NSLocalizedString(@"，", nil)]];
        NSMutableString *str1 = [NSMutableString string];
        for (int i = 0; i<ary1.count; i++) {
            NSString *strC = ary1[i];
            if (strC.length>5) {
                [ary1 removeObject:strC];
            }else {
                [str1 appendString:strC];
                [str1 appendString:@","];
            }
        }
        if (ary1.count != 0 && ary1.count<7) {
            [str1 deleteCharactersInRange:NSMakeRange(str1.length-1, 1)];
            
            [muDicParameters setObject:str1 forKey:@"goodatfield"];//我的爱好
            [self startEditeHobbyInfoWithDic:muDicParameters withType:2];
        }else {
            isShowTf2 = NO;
            muArySaveLoveBtn2 = [NSMutableArray array];
            [_mainTableView reloadData];
        }
    }else if (sender == btnOKLove3) {//我的需求
        NSMutableArray *ary1 = [NSMutableArray arrayWithArray:[tfLove3.text componentsSeparatedByString:NSLocalizedString(@"，", nil)]];
        NSMutableString *str1 = [NSMutableString string];
        for (int i = 0; i<ary1.count; i++) {
            NSString *strC = ary1[i];
            if (strC.length>5) {
                [ary1 removeObject:strC];
            }else {
                [str1 appendString:strC];
                [str1 appendString:@","];
            }
        }
        if (ary1.count != 0 && ary1.count<7) {
            [str1 deleteCharactersInRange:NSMakeRange(str1.length-1, 1)];
            
            [muDicParameters setObject:str1 forKey:@"myneeds"];//我的爱好
            [self startEditeHobbyInfoWithDic:muDicParameters withType:3];
        }else {
            isShowTf3 = NO;
            muArySaveLoveBtn3 = [NSMutableArray array];
            [_mainTableView reloadData];
        }
    }
}

#pragma mark - 添加 我的爱好 我的需求 擅长领域
- (void)startEditeHobbyInfoWithDic:(NSDictionary *)dicc withType:(NSInteger)type
{
    //token=验证用户&userId=用户id&hobby=我的爱好&myneeds=我的需求&goodatfield=我擅长的领域 多个用引文逗号隔开
    [self showRoundProgressWithTitle:@"请稍后..."];
    
    
    NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"addPeople_hobby_myneeds_goodatfield_app_myHome.im.lensum"];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:dicc progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            switch (type) {
                case 1://兴趣爱好
                {
                    NSArray *ary = [NSArray arrayWithArray:[dicc[@"hobby"] componentsSeparatedByString:NSLocalizedString(@",", nil)]];
                    muAryHobby = [NSMutableArray arrayWithArray:ary];
                    isShowTf1 = NO;
                    muArySaveLoveBtn1 = [NSMutableArray array];
                    [_dicInfo setObject:dicc[@"hobby"] forKey:@"hobby"];
                }
                    break;
                case 2://擅长领域
                {
                    NSArray *ary = [NSArray arrayWithArray:[dicc[@"goodatfield"] componentsSeparatedByString:NSLocalizedString(@",", nil)]];
                    muAryGoodatfield = [NSMutableArray arrayWithArray:ary];
                    isShowTf2 = NO;
                    muArySaveLoveBtn2 = [NSMutableArray array];
                    [_dicInfo setObject:dicc[@"goodatfield"] forKey:@"goodatfield"];
                }
                    break;
                case 3://我的需求
                {
                    NSArray *ary = [NSArray arrayWithArray:[dicc[@"myneeds"] componentsSeparatedByString:NSLocalizedString(@",", nil)]];
                    muAryMyneeds = [NSMutableArray arrayWithArray:ary];
                    isShowTf3 = NO;
                    muArySaveLoveBtn3 = [NSMutableArray array];
                    [_dicInfo setObject:dicc[@"myneeds"] forKey:@"myneeds"];
                }
                    break;
            }

            [self showRightWithTitle:[dicInfo objectForKey:@"msg"] autoCloseTime:2];
        }else {

           [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
        }

        [_mainTableView reloadData];

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showSingleIconBubble:error.localizedDescription];

    }];
}

#pragma mark - 添加教育经历
- (void)addEducation
{
    educationView *edu = [educationView sharedSelectedAddress];
    edu.delegatee = self;
    [edu addEduExpWith:self];
}

- (void)AddDelegateWithTime:(NSString *)time withSchoolName:(NSString *)schoolName withSchoolStudy:(NSString *)schoolStudy withLogo:(UIImage *)imgLogo
{
    //token=rE3F2m8AvfC7CVh85O9q&userId=用户id&time=2010.09-2015.06&schoolName=学校名称&schoolStudy=专业名称 参数说明：photo-为图片
    [self showRoundProgressWithTitle:@"请稍后..."];
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    
    [muDicParameters setObject:time forKey:@"time"];
    [muDicParameters setObject:schoolName forKey:@"schoolName"];
    [muDicParameters setObject:schoolStudy forKey:@"schoolStudy"];
    
    NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"addPeopleEducation_app_myHome.im.lensum"];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    [manager POST:strURl parameters:muDicParameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        NSData *imageData = UIImageJPEGRepresentation(imgLogo, 0.5);
        [formData appendPartWithFileData:imageData name:@"photo" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([dicInfo[@"result"] integerValue] == 1) {
            
            NSMutableDictionary *muDic = [NSMutableDictionary dictionary];
            [muDic setObject:dicInfo[@"data"] forKey:@"schoolLogo"];
            [muDic setObject:schoolStudy forKey:@"schoolStudy"];
            [muDic setObject:schoolName forKey:@"schoolName"];
            [muDic setObject:time forKey:@"schoolTime"];
            
            [muAryEducation addObject:muDic];

            [self showRightWithTitle:dicInfo[@"msg"] autoCloseTime:2];
            [self.mainTableView reloadData];
        }else {

            [self showSingleIconBubble:dicInfo[@"msg"]];
        }

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showSingleIconBubble:error.localizedDescription];

    }];
}

#pragma mark - 工作经验回调
- (void)AddDelegateWithTime:(NSString *)time withWorkName:(NSString *)schoolName withWorkPositionName:(NSString *)schoolStudy withLogo:(UIImage *)imgLogo
{
    //token=rE3F2m8AvfC7CVh85O9q&userId=用户id&time=2010.09-2015.06&workName=公司名称&workPositionName=担任职位 参数说明：photo-为图片

    [self showRoundProgressWithTitle:@"请稍后..."];
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    
    [muDicParameters setObject:time forKey:@"time"];
    [muDicParameters setObject:schoolName forKey:@"workName"];
    [muDicParameters setObject:schoolStudy forKey:@"workPositionName"];
    
    NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"addPeopleWork_app_myHome.im.lensum"];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    
    [manager POST:strURl parameters:muDicParameters constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        NSData *imageData = UIImageJPEGRepresentation(imgLogo, 0.5);
        [formData appendPartWithFileData:imageData name:@"photo" fileName:@"photo.jpg" mimeType:@"image/jpeg"];
        
    } progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([dicInfo[@"result"] integerValue] == 1) {
            
            NSMutableDictionary *muDic = [NSMutableDictionary dictionary];
            [muDic setObject:dicInfo[@"data"] forKey:@"workLogo"];
            [muDic setObject:schoolStudy forKey:@"workPosition"];
            [muDic setObject:schoolName forKey:@"workName"];
            [muDic setObject:time forKey:@"workTime"];
            
            [muAryWork addObject:muDic];

            [self showRightWithTitle:dicInfo[@"msg"] autoCloseTime:2];
            [self.mainTableView reloadData];
        }else {

            [self showSingleIconBubble:dicInfo[@"msg"]];
        }

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showSingleIconBubble:error.localizedDescription];

    }];
}

//侧滑－－删除
//先要设Cell可编辑
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return NO;
    }else if (indexPath.row < aryTitle1.count+1) {//个人信息
        return NO;
    }else if (indexPath.row < aryTitle1.count+1+3) {//爱好
        return NO;
    }else if (indexPath.row == aryTitle1.count+1+3) {//工作经历
        return NO;
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1) {
        return YES;
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1) {//添加工作经历
        return NO;
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+1) {//教育经历
        return NO;
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//
        return YES;
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//添加教育经历
        return NO;
    }else{
        return NO;
    }
}

//定义编辑样式
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete;
}

//进入编辑模式，按下出现的编辑按钮后
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        
    }else if (indexPath.row < aryTitle1.count+1) {//个人信息
        
    }else if (indexPath.row < aryTitle1.count+1+3) {//爱好
        
    }else if (indexPath.row == aryTitle1.count+1+3) {//工作经历
        
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1) {
        [self startDeleteWithId:indexPath withType:2];
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1) {//添加工作经历
        
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+1) {//教育经历
        
    }else if (indexPath.row < aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//
        [self startDeleteWithId:indexPath withType:1];
    }else if (indexPath.row == aryTitle1.count+1+3+muAryWork.count+1+2+muAryEducation.count) {//添加教育经历
        
    }
    
    
}

//修改编辑按钮文字
- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return @"删除";
}


#pragma mark - 删除数据
- (void)startDeleteWithId:(NSIndexPath *)indexPath withType:(NSInteger)deType
{
    [self showRoundProgressWithTitle:@"请稍后..."];
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:allConstMemberid forKey:@"userId"];
    [muDicParameters setObject:allConstMemberToken forKey:@"token"];//验证用户
    
    
    NSString *strURl;
    
    NSInteger roEdu = indexPath.row - aryTitle1.count - muAryWork.count - 7;
    NSInteger roWork = indexPath.row - aryTitle1.count - 5;
    if (deType == 1) {//教育
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"deletePeopleEducation_app_myHome.im.lensum"];
        
        [muDicParameters setObject:muAryEducation[roEdu][@"schoolName"] forKey:@"schoolName"];//学校名称
    }else {//工作
        strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"deletePeopleWork_app_myHome.im.lensum"];
        
        [muDicParameters setObject:muAryWork[roWork][@"workName"] forKey:@"workName"];//公司名称
    }
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
//        NSLog(@"%@",dicInfo);

        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            if (deType == 1) {//教育
                [muAryEducation removeObjectAtIndex:roEdu];
            }else {//工作
                [muAryWork removeObjectAtIndex:roWork];
            }
            [_mainTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

            [self showRightWithTitle:dicInfo[@"msg"] autoCloseTime:2];
        }else {

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
        }

    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

       [self showSingleIconBubble:error.localizedDescription];

    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
